#include "install.h"
#include "resource.h"
#include "utils.h"

#include <windowsx.h>

namespace
{
	static void Cls_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
	{
		switch (id)
		{
			case IDOK:
			{
				ShellExecute(hwnd, TEXT("open"), TEXT("Install.bat"), NULL, NULL, SW_SHOW);
			}
			case IDCANCEL:
				EndDialog(hwnd, 0);
				break;
			default:
				break;
		}
	}

	BOOL Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
	{
		SetIcon(hwnd, IDI_ICON1);
		return TRUE;
	}

	INT_PTR CALLBACK DialogMainProc(_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
	{
		switch (uMsg)
		{
			HANDLE_MSG_DLG(hwndDlg, WM_INITDIALOG, Cls_OnInitDialog);
			HANDLE_MSG_DLG(hwndDlg, WM_COMMAND, Cls_OnCommand);
			case WM_CLOSE:
				EndDialog(hwndDlg, 0);
				return TRUE;
			default:
				break;
		}
		return FALSE;
	}
}

CInstall::CInstall(HINSTANCE hInstance)
{
	DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_MAIN), NULL, DialogMainProc);
}
